1. Field of the Invention
The present invention relates to virtual machines within computer systems. More specifically, the present invention relates to a method and an apparatus for synchronous detection and signaling of memory quota violations for sequential memory allocation in a shared heap.
2. Related Art
The Java 2 Platform, Micro Edition (J2ME™), has become a very popular software platform for memory-constrained devices such as wireless devices. Motorola, Nokia, NTT DoCoMo, RIM, Siemens, and many other key players in the wireless device industry have shipped a large number of J2ME-enabled devices. In fact, based on some estimates, over 200 million J2ME-enabled mobile phones were shipped in 2003 alone.
A number of techniques to conserve memory have been developed to effectively run applications on such memory-constrained computing devices. One promising technique uses a shared heap to store objects from different tasks (or threads). This technique makes better use of memory space than the conventional technique, which uses a separate heap for each task. However, using a shared heap complicates both garbage-collection and memory-accounting operations.
In computing systems that do not have such memory constraints, data structures such as lookup tables can be used to keep track of per-task memory allocation. However, in memory-constrained computing devices, the high overhead required by such techniques can consume space and introduce time delays. Since modern programming languages (e.g. JAVA™) intensively allocate memory in heap, the speed of memory allocation is essential for program performance. One of the simplest and fastest memory-allocation techniques is sequential (or “pointer-bumping”) allocation. Such fast memory allocation techniques can be combined with approximate-memory-usage tracking to achieve performance goals. However, the techniques used to track approximate memory usage frequently only detect memory quota violations asynchronously to the time of the violation, which can lead to deviations in expected program behavior.
Hence, what is needed is a method and an apparatus for synchronously detecting and signaling memory quota violations for sequential memory allocation in a shared heap without the above-described problems.